package com.ldzy.dao;

import com.ldzy.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    @Select("select * from user where user=#{user} and password=#{password}")
    User login(User user);//登录
    @Select("select*from user where uClass=1")
    List<User> selectStaff();//查询员工
    @Select("select * from user where uid=#{uid}")
    User findById(int uid);//根据uid查询信息并返回
    @Update("<script>"+"update user <set>" +
            "<if test=\" name!=null\"> name=#{name},</if>" +
            "<if test=\" phone!=null\"> phone=#{phone},</if>" +
            "<if test=\" password!=null\"> password=#{password},</if>" +
            "</set>"+
            "where name=#{name}"+
            "</script>")
    int updateUser(User user);//根据id修改信息
    @Insert("insert into user(name,sex,phone,user,password) values(#{name},#{sex},#{phone},#{user},#{password})")
    int addUser(User user);//增加一个员工
    @Delete("delete from user where uid=#{uid}")
    int deleteById(int uid);//删除员工
}
